﻿@model IEnumerable<CSF.Customers.Data.Terms>
@{
    ViewBag.Title = "Index";
    ViewBag.SubTitle = "Terms";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="applicationPanel" class="easyui-panel" title="Grid" icon="icon-save" collapsible="true"
    style="width: auto; padding: 10px; background: #fafafa;">
    @using (Html.BeginForm("Index", "Terms", FormMethod.Get))
    { 
        @Html.Hidden("SessionId", Request["SessionId"])
        <div style="text-align: right">
            &nbsp;&nbsp;Code:<input id="Code" name="Code" />
            Name:<input id="Name1" name="Name1" />
            <a href="javascript:submitSearch();" class="easyui-linkbutton" iconcls="icon-search"
                plain="true">Search</a>
            <input id="search" type="submit" value="submit" style="display: none" />
        </div>
       
    }
    @using (Html.BeginForm("Delete", "Terms"))
    {
        @Html.Hidden("toUrl", Request.Url.ToString())
        <div id="toolbar" style="width: 90%">
            &nbsp;&nbsp;<input type="checkbox" id="chkAll" name="chkAll" />Select All&nbsp;&nbsp;
            <a href="@Url.Action("Add", "Terms")" class="easyui-linkbutton" iconcls="icon-add" plain="true">
                Add</a> &nbsp;&nbsp;<a href="javascript:submitToggleActive();" class="easyui-linkbutton"
                    iconcls="icon-no" plain="true">Delete</a>
        </div>
        <div id="grid">
            @{  var grid = new WebGrid(source: Model, defaultSort: "Code", rowsPerPage: 15, ajaxUpdateContainerId: "grid");    
                @grid.GetHtml(
                               tableStyle: "webGrid",
                               headerStyle: "header",
                               alternatingRowStyle: "alt",
                               footerStyle: "foot",
                                columns: grid.Columns(
                                               grid.Column(format: @<input  name="Code" type="checkbox" value="@item.Code" />),
                                                                                                   grid.Column("Code", "Code"),
                                                                                                   grid.Column("Name1", "Name1"),
                                                                                                   grid.Column("Name2", "Name2"),
                                                                                                   grid.Column("Name3", "Name3"),                                                                                                  
                                                                                                   grid.Column("Sequence", "Sequence"),
                                                                                                   grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { code = item.Code })),
                                                                                                                                           grid.Column(format: (item) => Html.ActionLink("Delete", "Delete", new { code = item.Code, toUrl = Request.Url.ToString() }))

                                                                                              ),
                                                                                fillEmptyRows: !IsPost,
                                                                                mode: WebGridPagerModes.All,
                                                                                firstText: "First Page",
                                                                                previousText: "Previous Page",
                                                                                nextText: "Next Page",
                                                                                lastText: "Last Page",
                                                                                numericLinksCount: 15

                                                                          ) 
            }
        </div>
        <br />
        <input id="submit" type="submit" value="submit" style="display: none" />    
    }
</div>
<script type="text/javascript">
    $('#chkAll').click(function () {
        $(':checkbox[name="Code"]').attr('checked', $(this).attr('checked'));
    });
    function submitToggleActive() {
        $('#submit').click();
    }
    function submitSearch() {
        $('#search').click();
    }
</script>
